home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume2 / contool3.0 / part04 < prev    next >
Encoding:
Internet Message Format  |  1990-09-25  |  21.7 KB

  1. Path: uunet!snorkelwacker!apple!sun-barr!rutgers!aramis.rutgers.edu!mcgrew
  2. From: mcgrew@aramis.rutgers.edu (Charles Mcgrew)
  3. Newsgroups: comp.sources.sun
  4. Subject: v02i023:  Contool 3.0, Part04/06
  5. Message-ID: <Sep.25.16.12.08.1990.25539@aramis.rutgers.edu>
  6. Date: 25 Sep 90 20:12:09 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 709
  9. Approved: mcgrew@aramis.rutgers.edu
  10.  
  11. Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano)
  12. Posting-number: Volume 2, Issue 23
  13. Archive-name: contool3.0/part04
  14.  
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 4 (of 6)."
  23. # Contents:  contool.c
  24. # Wrapped by chuck@melmac on Fri Aug 17 10:00:53 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'contool.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'contool.c'\"
  28. else
  29. echo shar: Extracting \"'contool.c'\" \(19504 characters\)
  30. sed "s/^X//" >'contool.c' <<'END_OF_FILE'
  31. X/************************************************************************/
  32. X/*    Copyright 1988-1990 by Chuck Musciano and Harris Corporation    */
  33. X/*                                    */
  34. X/*    Permission to use, copy, modify, and distribute this software    */
  35. X/*    and its documentation for any purpose and without fee is    */
  36. X/*    hereby granted, provided that the above copyright notice    */
  37. X/*    appear in all copies and that both that copyright notice and    */
  38. X/*    this permission notice appear in supporting documentation, and    */
  39. X/*    that the name of Chuck Musciano and Harris Corporation not be    */
  40. X/*    used in advertising or publicity pertaining to distribution    */
  41. X/*    of the software without specific, written prior permission.    */
  42. X/*    Chuck Musciano and Harris Corporation make no representations    */
  43. X/*    about the suitability of this software for any purpose.  It is    */
  44. X/*    provided "as is" without express or implied warranty.  This     */
  45. X/*    software may not be sold without the prior explicit permission    */
  46. X/*    of Harris Corporation.                        */
  47. X/************************************************************************/
  48. X
  49. X/************************************************************************/
  50. X/*                                    */
  51. X/*    contool.c    main contool driver                */
  52. X/*                                    */
  53. X/************************************************************************/
  54. X
  55. X#include    <stdio.h>
  56. X#include    <fcntl.h>
  57. X#include    <strings.h>
  58. X#include    <sys/ioctl.h>
  59. X#include    <sys/file.h>
  60. X#include    <sys/types.h>
  61. X#include    <sys/stat.h>
  62. X#include    <sys/param.h>
  63. X
  64. X#include    <X11/Xlib.h>
  65. X
  66. X#include    <xview/xview.h>
  67. X#include    <xview/icon.h>
  68. X#include    <xview/panel.h>
  69. X#include    <xview/textsw.h>
  70. X#include    <xview/xv_xrect.h>
  71. X
  72. X#include    "manifest.h"
  73. X#include    "contool.h"
  74. X#include    "contool_ui.h"
  75. X
  76. X#define        update_value(old, new)        ((old) = ((new) > (old))? (new) : (old))
  77. X
  78. X#define        INPUT_BUFFER_SIZE        4096
  79. X
  80. XEXPORT    Attr_attribute    INSTANCE;
  81. X
  82. XEXPORT    contool_base_objects    *contool_base;
  83. XEXPORT    char            *filter_file;
  84. X
  85. XPUBLIC    Server_image        load_icon();
  86. X
  87. XPRIVATE    short    good_bits[]  = {
  88. X#include    "icons/default_good.icon"
  89. X                   };
  90. XPRIVATE    short    bad_bits[]   = {
  91. X#include    "icons/default_bad.icon"
  92. X                   };
  93. XPRIVATE    short    flash_bits[] = {
  94. X#include    "icons/default_flash.icon"
  95. X                   };
  96. XPRIVATE    short    mask_bits[] = {
  97. X#include    "icons/mask.icon"
  98. X                   };
  99. X
  100. XPRIVATE    char            *ct_usage = "usage: contool [-c <file>] [-l] [-L <file>]\n";
  101. X
  102. XPRIVATE    Server_image        default_good_icon, good = NULL;
  103. XPRIVATE    Server_image        default_bad_icon, bad = NULL;
  104. XPRIVATE    Server_image        default_flash_icon, flash = NULL;
  105. XPRIVATE    Server_image        icon_mask;
  106. X
  107. XPRIVATE    int            bad_is_up;
  108. XPRIVATE    int            beep_count;
  109. XPRIVATE    int            blinking = FALSE;
  110. XPRIVATE    FILE            *command = NULL;
  111. XPRIVATE    Filter            *curr_filter = NULL;
  112. XPRIVATE    int            event_in_progress = FALSE;
  113. XPRIVATE    int            explicit_filters = FALSE;
  114. XPRIVATE    int            masking_works;
  115. XPRIVATE    FILE            *master = NULL;
  116. XPRIVATE    int            old_time = 0;
  117. XPRIVATE    char            *program;
  118. XPRIVATE    FILE            *slave = NULL;
  119. X
  120. XPRIVATE    struct    itimerval    timer = {{0, 500000}, {0, 500000}};
  121. X
  122. X/************************************************************************/
  123. X/*    Manage piping console output to a command             */
  124. X/************************************************************************/
  125. X
  126. X/************************************************************************/
  127. XPRIVATE    start_command(cmd)
  128. X
  129. Xchar    *cmd;
  130. X
  131. X{
  132. X    if (command)
  133. X       pclose(command);
  134. X    if ((command = popen(cmd, "w")) == NULL)
  135. X       internal_error("could not execute \"%s\"", cmd);
  136. X}
  137. X
  138. X/************************************************************************/
  139. XPRIVATE    continue_command(buf)
  140. X
  141. Xchar    *buf;
  142. X
  143. X{
  144. X    if (command)
  145. X       fprintf(command, buf);
  146. X}
  147. X
  148. X/************************************************************************/
  149. XPRIVATE    end_command()
  150. X
  151. X{
  152. X    if (command)
  153. X       pclose(command);
  154. X}
  155. X
  156. X/************************************************************************/
  157. X/*    Some basic console utility routines                 */
  158. X/************************************************************************/
  159. X
  160. X/************************************************************************/
  161. XEXPORT    acquire_console()
  162. X
  163. X{
  164. X    if (ioctl(fileno(slave), TIOCCONS, NULL) == -1)
  165. X       abend("%s: could not attach to /dev/console", program);
  166. X}
  167. X
  168. X/************************************************************************/
  169. XEXPORT    stop_blinking()
  170. X
  171. X{    Icon    icon;
  172. X
  173. X    notify_set_itimer_func(contool_base->base, NULL, ITIMER_REAL, NULL, NULL);
  174. X    icon = (Icon) xv_get(contool_base->base, FRAME_ICON);
  175. X    xv_set(icon, ICON_IMAGE, good, NULL);
  176. X    xv_set(contool_base->base, FRAME_ICON, icon, 0);
  177. X    blinking = FALSE;
  178. X}
  179. X
  180. X/************************************************************************/
  181. XEXPORT    filters_changed()
  182. X
  183. X{
  184. X    curr_filter = NULL;
  185. X    xv_set(contool_base->base, FRAME_LEFT_FOOTER, "", NULL);
  186. X    end_command();
  187. X}
  188. X
  189. X/************************************************************************/
  190. X/*    Various small features                        */
  191. X/************************************************************************/
  192. X
  193. X/************************************************************************/
  194. XEXPORT    Menu_item    print_messages(item, op)
  195. X
  196. XMenu_item    item;
  197. XMenu_generate    op;
  198. X
  199. X{    int    size;
  200. X    char    *buf;
  201. X    FILE    *cmd;
  202. X
  203. X    if (op == MENU_NOTIFY) {
  204. X       if (is_empty(defaults.print_filter))
  205. X          error("You must specify a printer command in the Properties dialog");
  206. X       else if ((cmd = popen(defaults.print_filter, "w")) == NULL)
  207. X          error("Could not execute %s", defaults.print_filter);
  208. X       else {
  209. X          xv_set(contool_base->base, FRAME_BUSY, TRUE, NULL);
  210. X          size = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  211. X          buf = (char *) malloc(size);
  212. X          xv_get(contool_base->display, TEXTSW_CONTENTS, 0, buf, size);
  213. X          if (fwrite(buf, 1, size, cmd) != size)
  214. X             error("Could not write console contents to printer");
  215. X          pclose(cmd);
  216. X          xv_set(contool_base->base, FRAME_BUSY, FALSE, NULL);
  217. X          }
  218. X       }
  219. X    return item;
  220. X}
  221. X
  222. X/************************************************************************/
  223. XEXPORT    Menu_item    become_console(item, op)
  224. X
  225. XMenu_item    item;
  226. XMenu_generate    op;
  227. X
  228. X{
  229. X    if (op == MENU_NOTIFY)
  230. X       acquire_console();
  231. X    return item;
  232. X}
  233. X
  234. X/************************************************************************/
  235. XEXPORT    Menu_item    clear_messages(item, op)
  236. X
  237. XMenu_item    item;
  238. XMenu_generate    op;
  239. X
  240. X{
  241. X    if (op == MENU_NOTIFY) {
  242. X       textsw_reset(contool_base->display, 0, 0);
  243. X       old_time = 0;
  244. X       }
  245. X    return item;
  246. X}
  247. X
  248. X/************************************************************************/
  249. XEXPORT    Menu_item    reset_filter(item, op)
  250. X
  251. XMenu_item    item;
  252. XMenu_generate    op;
  253. X
  254. X{
  255. X    if (op == MENU_NOTIFY)
  256. X       filters_changed();
  257. X    return item;
  258. X}
  259. X
  260. X/************************************************************************/
  261. XPRIVATE    change_icon(image, use_mask)
  262. X
  263. XServer_image    image;
  264. Xint        use_mask;
  265. X
  266. X{    Icon    icon;
  267. X
  268. X    icon = (Icon) xv_get(contool_base->base, FRAME_ICON);
  269. X    xv_set(icon,
  270. X          ICON_IMAGE, image,
  271. X          XV_WIDTH, (int) xv_get(image, XV_WIDTH),
  272. X          XV_HEIGHT, (int) xv_get(image, XV_HEIGHT),
  273. X           NULL);
  274. X    if (masking_works && use_mask)
  275. X       xv_set(icon, ICON_MASK_IMAGE, icon_mask, NULL);
  276. X    xv_set(contool_base->base, FRAME_ICON, icon, NULL);
  277. X}
  278. X
  279. X/************************************************************************/
  280. XEXPORT    update_icons()
  281. X
  282. X{    char    msg[1024];
  283. X
  284. X    if (good && good != default_good_icon)
  285. X       xv_destroy(good);
  286. X    if (bad && bad != default_bad_icon)
  287. X       xv_destroy(bad);
  288. X    if (flash && flash != default_flash_icon)
  289. X       xv_destroy(flash);
  290. X
  291. X    good  = (defaults.good_icon  == NULL)? default_good_icon  : load_icon(defaults.good_icon, msg);
  292. X    bad   = (defaults.bad_icon   == NULL)? default_bad_icon   : load_icon(defaults.bad_icon, msg);
  293. X    flash = (defaults.flash_icon == NULL)? default_flash_icon : load_icon(defaults.flash_icon, msg);
  294. X
  295. X    if (!blinking)
  296. X       change_icon(good, good == default_good_icon);
  297. X}
  298. X
  299. X/************************************************************************/
  300. X/*    Now, filter  handlers                        */
  301. X/************************************************************************/
  302. X
  303. X/************************************************************************/
  304. XPRIVATE    internal_message(a, b, c, d, e, f)
  305. X
  306. Xint    a, b, c, d, e, f;
  307. X
  308. X{    char    buf[1024];
  309. X
  310. X    sprintf(buf, a, b, c, d, e, f);
  311. X    time_stamp();
  312. X    write_log(buf);
  313. X    do_insertion(buf, strlen(buf));
  314. X}
  315. X
  316. X/************************************************************************/
  317. XPRIVATE    internal_error(a, b, c, d, e, f)
  318. X
  319. Xint    a, b, c, d, e, f;
  320. X
  321. X{    char    buf[1024];
  322. X
  323. X    sprintf(buf, a, b, c, d, e, f);
  324. X    time_stamp();
  325. X    fprintf(stderr, "*** %s: %s\n", program, buf);
  326. X}
  327. X
  328. X/************************************************************************/
  329. XPRIVATE    load_filters()
  330. X
  331. X{    struct    stat    sb;
  332. X    static    int    load_time = 0;
  333. X
  334. X    if (access(filter_file, R_OK) == -1) {
  335. X       if (explicit_filters && load_time == 0) {
  336. X          internal_error("filter file %s cannot be accessed", filter_file);
  337. X          load_time = 1;
  338. X          }
  339. X       }
  340. X    else if (stat(filter_file, &sb) == 0 && sb.st_mtime > load_time)
  341. X       if (lex_init(filter_file)) {
  342. X          yyparse();
  343. X          if (!parse_errors_occured) {
  344. X             free_list(filters);
  345. X             free(parsed_defaults);
  346. X             filters = parsed_filters;
  347. X             internal_message("*** filters loaded from %s\n", filter_file);
  348. X             load_time = sb.st_mtime;
  349. X             }
  350. X          }
  351. X       else {
  352. X          internal_error("error accessing configuration file %s", filter_file);
  353. X          load_time = 1;
  354. X          }
  355. X}
  356. X
  357. X/************************************************************************/
  358. X/*    Various event handlers for the console frame            */
  359. X/************************************************************************/
  360. X
  361. X/************************************************************************/
  362. XPRIVATE    Notify_value    blink_proc(me, which)
  363. X
  364. Xint    *me;
  365. Xint    which;
  366. X
  367. X{
  368. X    if (event_in_progress)
  369. X       return(NOTIFY_DONE);
  370. X    if (beep_count > 0) {
  371. X       window_bell(contool_base->base);
  372. X       beep_count--;
  373. X       }
  374. X    if (blinking) {
  375. X       if (bad_is_up)
  376. X          change_icon(flash, flash == default_flash_icon);
  377. X       else
  378. X          change_icon(bad, bad == default_bad_icon);
  379. X       bad_is_up = !bad_is_up;
  380. X       }
  381. X    if (beep_count == 0 && !blinking)
  382. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, NULL, NULL);
  383. X    return(NOTIFY_DONE);
  384. X}
  385. X
  386. X/************************************************************************/
  387. XPRIVATE    Notify_value    close_proc(frame, event, arg, type)
  388. X
  389. XFrame    frame;
  390. XEvent    *event;
  391. XNotify_arg    arg;
  392. XNotify_event_type    type;
  393. X
  394. X{
  395. X    event_in_progress = TRUE;
  396. X    if (event_action(event) == ACTION_OPEN && blinking) {
  397. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, NULL, NULL);
  398. X       change_icon(good, good = default_good_icon);
  399. X       blinking = FALSE;
  400. X       }
  401. X    event_in_progress = FALSE;
  402. X    return(notify_next_event_func(frame, event, arg, type));
  403. X}
  404. X
  405. X/************************************************************************/
  406. XPRIVATE    Notify_value    destroy_proc(frame, status)
  407. X
  408. XFrame    frame;
  409. XDestroy_status    status;
  410. X
  411. X{
  412. X    if (status == DESTROY_CHECKING) {
  413. X       textsw_reset(contool_base->display, 0, 0);
  414. X       return(NOTIFY_DONE);
  415. X       }
  416. X    else
  417. X       return(notify_next_destroy_func(frame, status));
  418. X}
  419. X
  420. X/************************************************************************/
  421. X/*    Routines which handle capturing and displaying messages        */
  422. X/************************************************************************/
  423. X
  424. X/************************************************************************/
  425. XPRIVATE    do_insertion(buf, len)
  426. X
  427. Xchar    *buf;
  428. Xint    len;
  429. X
  430. X{    int    first, last, sw_len;
  431. X    char    *temp;
  432. X
  433. X    while ((int) xv_get(contool_base->display, TEXTSW_LENGTH) + len > defaults.max_size) {
  434. X       first = 1;
  435. X       last = TEXTSW_INFINITY;
  436. X       if (textsw_find_bytes(contool_base->display, &first, &last, "\n<<<", 4, 0) == -1)
  437. X          if (textsw_find_bytes(contool_base->display, &first, &last, "\n", 1, 0) == -1)
  438. X             first = defaults.delete_amount;
  439. X       textsw_erase(contool_base->display, 0, first + 1);
  440. X       sw_len = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  441. X       temp = (char *) malloc((unsigned) sw_len);
  442. X       xv_get(contool_base->display, TEXTSW_CONTENTS, 0, temp, sw_len);
  443. X       textsw_reset(contool_base->display, 0, 0);
  444. X       textsw_insert(contool_base->display, temp, sw_len);
  445. X       free(temp);
  446. X       }
  447. X    xv_set(contool_base->display, TEXTSW_INSERTION_POINT, TEXTSW_INFINITY, 0);
  448. X    textsw_insert(contool_base->display, buf, len);
  449. X}
  450. X
  451. X/************************************************************************/
  452. XPRIVATE    time_stamp()
  453. X
  454. X{    int    t, pos;
  455. X    char    buf[5];
  456. X
  457. X       t = time(0);
  458. X       if (t - old_time >= defaults.stamp_resolution) {
  459. X          xv_set(contool_base->display, TEXTSW_INSERTION_POINT, TEXTSW_INFINITY, 0);
  460. X          pos = (int) xv_get(contool_base->display, TEXTSW_LENGTH);
  461. X          if (pos != 0) {
  462. X             xv_get(contool_base->display, TEXTSW_CONTENTS, pos - 1, buf, 1);
  463. X             if (buf[0] != '\n')
  464. X                do_insertion("\n", 1);
  465. X             }
  466. X          do_insertion("\n<<< ", 5);
  467. X          do_insertion(ctime(&t), 24);
  468. X          do_insertion(" >>>\n", 5);
  469. X          old_time = t;
  470. X          }
  471. X}
  472. X
  473. X/************************************************************************/
  474. XPRIVATE    Notify_value    input_func(me, fd)
  475. X
  476. Xint    *me;
  477. Xint    fd;
  478. X
  479. X{    char    old_c, *s, *t, buf[1024];
  480. X    Filter    *f;
  481. X    int    count, do_blink = FALSE, do_open = FALSE;
  482. X    static    char    in_buf[INPUT_BUFFER_SIZE + 2];
  483. X
  484. X    while ((count = read(fileno(master), in_buf, INPUT_BUFFER_SIZE)) >= 0) {
  485. X       in_buf[count] = '\0';
  486. X       while (s = index(in_buf, '\015')) {
  487. X          strcpy(s, s + 1);
  488. X          count--;
  489. X          }
  490. X       for (t = in_buf; *t; *s = old_c, t = s) {
  491. X          if (s = index(t, '\n')) {
  492. X             old_c = *++s;
  493. X             *s = '\0';
  494. X             }
  495. X          else {
  496. X             s = t + strlen(t);
  497. X             old_c = '\0';
  498. X             }
  499. X          if (!defaults.log_after)
  500. X             write_log(t);
  501. X          if (curr_filter == NULL) {
  502. X             load_filters();
  503. X             for (f = filters; f; f = f->next)
  504. X                if (f->start_re && match_exp(f->start_re, f->start_circf, t)) {
  505. X                   if (f->save) {
  506. X                      update_value(do_blink, f->flash);
  507. X                      update_value(beep_count, f->beep);
  508. X                      update_value(do_open, f->open);
  509. X                      if (f->stamp)
  510. X                         time_stamp();
  511. X                      do_insertion(t, strlen(t));
  512. X                      if (f->command) {
  513. X                         start_command(f->command);
  514. X                         continue_command(t);
  515. X                         if (f->stop == NULL)
  516. X                            end_command();
  517. X                         }
  518. X                      if (defaults.log_after)
  519. X                 write_log(t);
  520. X                      }
  521. X                   if (f->stop) {
  522. X                      curr_filter = f;
  523. X                      sprintf(buf, "Filtering \"%s\"...", f->start);
  524. X                      xv_set(contool_base->base, FRAME_LEFT_FOOTER, buf, NULL);
  525. X                      }
  526. X                   break;
  527. X                   }
  528. X             if (f == NULL) {
  529. X                if (defaults.stamp)
  530. X                   time_stamp();
  531. X                if (defaults.command) {
  532. X                   start_command(defaults.command);
  533. X                   continue_command(t);
  534. X                   end_command();
  535. X                   }
  536. X            if (defaults.log_after)
  537. X                   write_log(t);
  538. X                do_insertion(t, strlen(t));
  539. X                update_value(do_blink, defaults.flash);
  540. X                update_value(do_open, defaults.open);
  541. X                update_value(beep_count, defaults.beep);
  542. X                }
  543. X             }
  544. X          else {
  545. X             if (curr_filter->save) {
  546. X                if (curr_filter->stamp)
  547. X                   time_stamp();
  548. X            if (defaults.log_after)
  549. X                   write_log(t);
  550. X            do_insertion(t, strlen(t));
  551. X            if (curr_filter->command)
  552. X               continue_command(t);
  553. X                }
  554. X             if (match_exp(curr_filter->stop_re, curr_filter->stop_circf, t)) {
  555. X                xv_set(contool_base->base, FRAME_LEFT_FOOTER, "", NULL);
  556. X                if (curr_filter->command)
  557. X                   end_command();
  558. X                curr_filter = NULL;
  559. X                }
  560. X             }
  561. X          }
  562. X       }
  563. X    xv_set(contool_base->display, TEXTSW_UPDATE_SCROLLBAR, 0);
  564. X    if (do_open)
  565. X       xv_set(contool_base->base, FRAME_CLOSED, FALSE, 0);
  566. X    if (do_blink)
  567. X       if (xv_get(contool_base->base, FRAME_CLOSED) && !blinking) {
  568. X          change_icon(bad, bad == default_bad_icon);
  569. X          xv_set(contool_base->base, WIN_SHOW, TRUE, 0);
  570. X          blinking = TRUE;
  571. X          bad_is_up = TRUE;
  572. X          notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, &timer, NULL);
  573. X          }
  574. X    if (beep_count > 0 || blinking)
  575. X       notify_set_itimer_func(contool_base->base, blink_proc, ITIMER_REAL, &timer, NULL);
  576. X    return(NOTIFY_DONE);
  577. X}
  578. X
  579. X/************************************************************************/
  580. X/*    Routines which parse options, create windows, and main()    */
  581. X/************************************************************************/
  582. X
  583. X/************************************************************************/
  584. XPRIVATE    parse_options(argc, argv)
  585. X
  586. Xint    *argc;
  587. Xchar    **argv;
  588. X
  589. X{    char    *s, c, path[1024], *log_file = NULL;
  590. X    int    log = FALSE;
  591. X
  592. X    sprintf(path, "%s/.contool", getenv("HOME"));
  593. X    filter_file = strsave(path);
  594. X
  595. X    while ((c = getopt(argc, argv, "c:lL:?", &s)) != EOF)
  596. X       switch (c) {
  597. X          case 'c' : filter_file = expand_tilde(s);
  598. X                   explicit_filters = TRUE;
  599. X                   break;
  600. X          case 'l' : log = TRUE;
  601. X                   break;
  602. X          case 'L' : log_file = expand_tilde(s);
  603. X                   break;
  604. X          case '?' : fprintf(stderr, ct_usage);
  605. X                   exit(0);
  606. X                   break;
  607. X          default  : fprintf(stderr, ct_usage);
  608. X                     exit(1);
  609. X          }
  610. X
  611. X    if (lex_init(filter_file)) {
  612. X       yyparse();
  613. X       if (parsed_defaults)
  614. X          defaults = *parsed_defaults;
  615. X       if (log_file)
  616. X          defaults.log_file = log_file;
  617. X       if (log)
  618. X          enable_logging();
  619. X       }
  620. X    else if (explicit_filters)
  621. X       error("Could not read configuration file %s", filter_file);
  622. X}
  623. X
  624. X/************************************************************************/
  625. Xmain(argc, argv)
  626. X
  627. Xint    argc;
  628. Xchar    **argv;
  629. X
  630. X{    char    buf[1024], *path, *open_psuedo_tty();
  631. X    int    i;
  632. X    XWindowAttributes    attr;
  633. X
  634. X    program = strsave(argv[0]);
  635. X
  636. X    path = open_psuedo_tty(&master, "r", &slave, "w");
  637. X    if (master == NULL)
  638. X       abend("%s: couldn't open any psuedo-tty", program);
  639. X    if (slave == NULL)
  640. X       abend("%s: couldn't open slave side of %s", program, path);
  641. X
  642. X    i = fcntl(fileno(master), F_GETFL, 0);
  643. X    i |= FNDELAY;
  644. X    if (fcntl(fileno(master), F_SETFL, i) == -1)
  645. X       abend("%s: could not force %s to non-blocking i/o", program);
  646. X
  647. X    acquire_console(path);
  648. X
  649. X    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
  650. X    INSTANCE = xv_unique_key();
  651. X
  652. X    contool_base = contool_base_objects_initialize(NULL, NULL);
  653. X    default_good_icon  = (Server_image) xv_create(NULL, SERVER_IMAGE,
  654. X                             XV_WIDTH, 64,
  655. X                             XV_HEIGHT, 64,
  656. X                             SERVER_IMAGE_BITS, good_bits,
  657. X                              NULL);
  658. X    default_bad_icon   = (Server_image) xv_create(NULL, SERVER_IMAGE,
  659. X                             XV_WIDTH, 64,
  660. X                             XV_HEIGHT, 64,
  661. X                             SERVER_IMAGE_BITS, bad_bits,
  662. X                              NULL);
  663. X    default_flash_icon = (Server_image) xv_create(NULL, SERVER_IMAGE,
  664. X                             XV_WIDTH, 64,
  665. X                             XV_HEIGHT, 64,
  666. X                             SERVER_IMAGE_BITS, flash_bits,
  667. X                              NULL);
  668. X    icon_mask          = (Server_image) xv_create(NULL, SERVER_IMAGE,
  669. X                             XV_WIDTH, 64,
  670. X                             XV_HEIGHT, 64,
  671. X                             SERVER_IMAGE_BITS, mask_bits,
  672. X                              NULL);
  673. X    disable_logging(contool_base);
  674. X
  675. X    XGetWindowAttributes(xv_get(contool_base->base, XV_DISPLAY), xv_get(xv_get(contool_base->base, XV_ROOT), XV_XID), &attr);
  676. X    masking_works = (attr.depth > 1);
  677. X
  678. X    parse_options(&argc, argv);
  679. X    load_filters();
  680. X    update_icons();
  681. X
  682. X    notify_set_input_func(contool_base->base, input_func, fileno(master));
  683. X    notify_interpose_destroy_func(contool_base->base, destroy_proc);
  684. X    notify_interpose_event_func(contool_base->base, close_proc, NOTIFY_SAFE);
  685. X
  686. X    xv_main_loop(contool_base->base);
  687. X    exit(0);
  688. X}
  689. END_OF_FILE
  690. if test 19504 -ne `wc -c <'contool.c'`; then
  691.     echo shar: \"'contool.c'\" unpacked with wrong size!
  692. fi
  693. # end of 'contool.c'
  694. fi
  695. echo shar: End of archive 4 \(of 6\).
  696. cp /dev/null ark4isdone
  697. MISSING=""
  698. for I in 1 2 3 4 5 6 ; do
  699.     if test ! -f ark${I}isdone ; then
  700.     MISSING="${MISSING} ${I}"
  701.     fi
  702. done
  703. if test "${MISSING}" = "" ; then
  704.     echo You have unpacked all 6 archives.
  705.     rm -f ark[1-9]isdone
  706. else
  707.     echo You still need to unpack the following archives:
  708.     echo "        " ${MISSING}
  709. fi
  710. ##  End of shell archive.
  711. exit 0
  712.  
  713. Chuck Musciano                ARPA  : chuck@trantor.harris-atd.com
  714. Harris Corporation             Usenet: ...!uunet!x102a!trantor!chuck
  715. PO Box 37, MS 3A/1912            AT&T  : (407) 727-6131
  716. Melbourne, FL 32902            FAX   : (407) 727-{5118,5227,4004}
  717.  
  718. I'm glad you asked, son.  Being popular
  719.     is the most important thing in the world.    -- Homer Simpson
  720.